package com.diver.flinkdemo.Trd.yzh;

import com.alibaba.fastjson.JSONObject;
import com.diver.flinkdemo.utils.FlinkThreadUtil;
import com.diver.flinkdemo.utils.Trd.YzhRequestUtil;
import com.diver.flinkdemo.utils.TrdUrlUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @Description 调用翼智慧云教平台接口，推送信息
 * @author hesc
 * @date 2021-11-10
 */
@Slf4j
public class YiZiHuiController {
    private FlinkThreadUtil threadUtil = new FlinkThreadUtil();

    private YzhRequestUtil yzhRequestUtil = new YzhRequestUtil();

    /**
     * 翼智慧平台推送数据
     * @param data
     */
    public void yiZiHuiDeal(String data){
        threadUtil.threadPoolExecutor().submit(new Runnable() {
            @Override
            public void run() {
                log.info("翼智慧平台推送数据：{}", data);
                JSONObject jo = JSONObject.parseObject(data);
                String url = TrdUrlUtil.YZH_URL + jo.getString("url");
                String result = yzhRequestUtil.post(url, jo.getJSONObject("params"));
                log.info("翼智慧{} 返回:{}", url, result);
            }
        });
    }

    /**
     * 翼智慧上海百学平台推送数据
     * @param data
     */
    public void shangHaiBXDeal(String data){
        threadUtil.threadPoolExecutor().submit(new Runnable() {
            @Override
            public void run() {
                log.info("翼智慧上海百学平台推送数据：{}", data);
                JSONObject jo = JSONObject.parseObject(data);
                String url = TrdUrlUtil.SHBX_URL + jo.getString("url");
                String result = yzhRequestUtil.post(url, jo.getJSONObject("params"));
                log.info("翼智慧上海百学{} 返回:{}", jo.getString("url"), result);
            }
        });
    }
}
